/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.purpose.utils;

public enum BusinessCode {

    SUCCESS(0, "success"),
    FAILURE(-1, "fail"),
    EXCEPTION(-2, "执行过程中发生异常"),
    KPI_NAME_DUP(92001, "考核项名称重复"),
    PARTIAL_SAVE_SUCCESS(92002, "因考核项名称重复等原因, 仅部分考核项存储成功"),
    ENTIRE_SAVE_FAILURE(92003, "因考核项名称重复等原因, 存储失败"),
    NO_LOGIN(10000, "用户未登陆"),
    INSUFFICIENT_PARAM(92005, "缺少必要的参数"),
    CONTRACT_NAME_DUP(92006, "责任书名称重复"),
    KPI_CODE_DUP(92001, "考核项编码重复"),
    HAZARD_LIBRARY_NAME_EMPTY(92007,"危害因素名称不能为空"),
    HAZARD_LIBRARY_NAME_DOUBLE(92008,"危害因素名称不能重复"),
    ;
    private final int code;
    private final String description;

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    BusinessCode(int code, String description) {
        this.code = code;
        this.description = description;
    }
    public static BusinessCode valueOf(int value){
        switch (value){
            case 0:
                return SUCCESS;
            case -1:
                return FAILURE;
            case -2:
                return EXCEPTION;
            case 92001:
                return KPI_NAME_DUP;
            case 92002:
                return PARTIAL_SAVE_SUCCESS;
            case 92003:
                return ENTIRE_SAVE_FAILURE;
            case 92004:
                return NO_LOGIN;
            case 92005:
                return INSUFFICIENT_PARAM;
            case 92006:
                return CONTRACT_NAME_DUP;
            case 92007:
                return HAZARD_LIBRARY_NAME_EMPTY;
            case 92008:
                return HAZARD_LIBRARY_NAME_DOUBLE;
            default:
                return null;
        }
    }

}
